<?php
session_start();
if (isset($_POST['openid']) && !empty($_POST['openid'])){
    include '../c/config.php';
    $mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
    if (!$mysqli->set_charset("utf8")) {}
    $openid=addslashes(trim($_POST['openid']));
    $phone=addslashes(trim($_POST['phone']));
    $name=addslashes(trim($_POST['name']));
    $sex=addslashes(trim($_POST['sex']));
    $gao=addslashes(trim($_POST['gao']));
    $weight=addslashes(trim($_POST['weight']));
    $age=addslashes(trim($_POST['age']));
    $idcard=addslashes(trim($_POST['idcard']));
    $qiuyi=addslashes(trim($_POST['qiuyi']));

    $query=$mysqli->query("SELECT id FROM uinfo where openid='".$openid."' limit 0,1 ");
    if($query->num_rows>0){
        $mysqli->query("update uinfo set phone='".$phone."',sex='".$sex."',gao='".$gao."',weight='".$weight."',age='".$age."',$idcard='".$idcard."' where openid='".$openid."', qiuyi='".$qiuyi."' ");
    }else{
        $mysqli->query("insert into uinfo(openid,phone,name,sex,gao,weight,age,idcard,qiuyi,createtime) values('".$openid."','".$phone."','".$name."','".$sex."','".$gao."','".$weight."','".$age."','".$idcard."','".$qiuyi."','".date("Y-m-d H:i:s")."')  ");
    }
    $mysqli->close();
    
    echo json_encode(array('s'=>'y'));
}

